﻿<UserControl x:Class="TransitionsLib.TransitionConrol"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:TransitionsLib"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        

        <Style TargetType="{x:Type ContentPresenter}">
            <Setter Property="LayoutTransform">
                <Setter.Value>
                    <ScaleTransform />
                </Setter.Value>
            </Setter>
        </Style>

        <local:CenterConverter x:Key="centerConverter"/>

        <!-- Slide and Fade -->
        <Storyboard x:Key="SlideAndFadeIn">
            <ThicknessAnimation Duration="0:0:.75" Storyboard.TargetProperty="Margin" 
                                Timeline.DesiredFrameRate="30"
                                From="500,0,-500,0" To="0" DecelerationRatio=".9" />
            <DoubleAnimation Duration="0:0:.25" Storyboard.TargetProperty="Opacity" 
                             Timeline.DesiredFrameRate="30"
                             From="0" To="1" />
        </Storyboard>

        <Storyboard x:Key="SlideAndFadeOut">
            <ThicknessAnimation Duration="0:0:.5" Storyboard.TargetProperty="Margin" 
                                Timeline.DesiredFrameRate="30"
                                To="-500,0,500,0" AccelerationRatio=".9"/>
            <DoubleAnimation Duration="0:0:.5" Storyboard.TargetProperty="Opacity" To="0" 
                             Timeline.DesiredFrameRate="30"/>
        </Storyboard>

        <!-- Fade -->
        <Storyboard x:Key="FadeIn" >
            <DoubleAnimation Duration="0:0:.25" Storyboard.TargetProperty="Opacity" 
                             Timeline.DesiredFrameRate="30"
                             From="0" To="1" />
        </Storyboard>

        <Storyboard x:Key="FadeOut">
            <DoubleAnimation Duration="0:0:.5" Storyboard.TargetProperty="Opacity" To="0" 
                             Timeline.DesiredFrameRate="30"/>
        </Storyboard>

        <!-- Slide -->
        <Storyboard x:Key="SlideIn" >
            <ThicknessAnimation Duration="0:0:.75" Storyboard.TargetProperty="Margin"
                                Timeline.DesiredFrameRate="30"
                                From="500,0,-500,0" To="0" DecelerationRatio=".9" />
        </Storyboard>

        <Storyboard x:Key="SlideOut">
            <ThicknessAnimation Duration="0:0:.5" Storyboard.TargetProperty="Margin"
                                Timeline.DesiredFrameRate="30"
                                To="-500,0,500,0" AccelerationRatio=".9"/>
        </Storyboard>
    </UserControl.Resources>

    <Grid>
        <ContentControl Name="contentPresenter">
            <ContentControl.RenderTransform>
                <TransformGroup>
                    <TranslateTransform X="0" Y="0" />
                </TransformGroup>
            </ContentControl.RenderTransform>
        </ContentControl>

    </Grid>
</UserControl>
